// 表单验证
// is_show_layer_error_msg  是否弹窗显示错误信息
function formValidate(is_show_layer_error_msg) {
    $("#form").validate({
        ignore: "", // 包括所有选项卡中的表单元素
        errorPlacement: function(error, element) { // 错误信息位置设置方法
            if ($(element).attr("class").indexOf("select2") > -1 || $(element).attr("class").indexOf("gaodemap") > -1 || ["radio", "checkbox"].includes($(element).attr("type"))) {
                $(element).parent().parent().find(".error-box").eq(0).after(error);
            }else if($(element).attr("class").indexOf("editormd-markdown-textarea") > -1){
                $(element).parent().parent().find(".error-box").eq(0).after(error);
            } else {
                element.after(error);
            }
        }
    });
    if (!$("#form").valid() && is_show_layer_error_msg) {
        top.layer.msg('表单填写有误,请检查！', {
            icon: 5,
            time: 2000,
            shade: [0.6, '#000', false]
        });
    }
}
// 弹出tips信息
// that 点击对象
function showTips(that) {
    if (window.hasOwnProperty('layerTips') && window.layerTips > -1) {
        layer.close(window.layerTips);
        window.layerTips = -1;
        if (window.hasOwnProperty('layerTips') && window.layerTipsThisId != $(that).attr('timestamp')) {
            window.layerTips = layer.tips($(that).attr('tips'), that, {
                time: $(that).attr('time'),
                tips: [$(that).attr('direction'), $(that).attr('background')]
            });
            window.layerTipsThisId = Date.now();
            $(that).attr('timestamp',window.layerTipsThisId);
        } else {
            window.layerTipsThisId = -1;
            $(that).attr('timestamp',window.layerTipsThisId);
        }
    } else {
        window.layerTips = layer.tips($(that).attr('tips'), that, {
            time: $(that).attr('time'),
            tips: [$(that).attr('direction'), $(that).attr('background')]
        });
        window.layerTipsThisId = Date.now();
        $(that).attr('timestamp',window.layerTipsThisId);
    }
}